package com.lxy.sentinel.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author lixinyang
 * @className: HotSpotController
 * @description: TODO
 * @date 2022/04/28日  21:18
 */

@RestController
@Slf4j
public class HotSpotController {

    @RequestMapping("/hotSpot1")
    @SentinelResource(value = "hotSpot1",blockHandler = "deal_test_fail")
    public String hotSpot1(@RequestParam("p1") Long p1,@RequestParam("p2") String p2){
        log.info("访问编号为:{}的商品{}",p1,p2);
        return "hotSpot1";
    }


    public String deal_test_fail(Long productId, BlockException e){
        return "热点数据访问失败";
    }
}

